//
//  TeamSelectViewController.m
//  SportsApp
//
//  Created by Matthew Moritz on 2012-11-29.
//  Copyright (c) 2012 Matthew Moritz. All rights reserved.
//
//  This is not the most efficient way to do this... I tried to work with the UICollection
//  View, but it wasn't working properly.
//

#import "TeamSelectViewController.h"

@interface TeamSelectViewController ()

@end

@implementation TeamSelectViewController

@synthesize button100;
@synthesize button101;
@synthesize button102;
@synthesize button103;
@synthesize button104;
@synthesize button105;
@synthesize button106;
@synthesize button107;
@synthesize button108;
@synthesize button109;
@synthesize button110;
@synthesize button111;
@synthesize button112;
@synthesize button113;
@synthesize button114;
@synthesize button115;
@synthesize button116;
@synthesize button117;
@synthesize button118;
@synthesize button119;
@synthesize button120;
@synthesize button121;
@synthesize button122;
@synthesize button123;
@synthesize button124;
@synthesize button125;
@synthesize button126;
@synthesize button127;
@synthesize button128;
@synthesize button129;

@synthesize teamName;

@synthesize teamSegmentButton;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/**
 *
 * Switches the conference that is currently visible
 */
- (IBAction)toggleConference:(id)sender {
    
    if([sender selectedSegmentIndex] == 0) {

        // show Eastern Conference teams
        button100.hidden = NO;
        button101.hidden = NO;
        button102.hidden = NO;
        button103.hidden = NO;
        button104.hidden = NO;
        button105.hidden = NO;
        button106.hidden = NO;
        button107.hidden = NO;
        button108.hidden = NO;
        button109.hidden = NO;
        button110.hidden = NO;
        button111.hidden = NO;
        button112.hidden = NO;
        button113.hidden = NO;
        button114.hidden = NO;
        
        // hide Western Conference teams
        button115.hidden = YES;
        button116.hidden = YES;
        button117.hidden = YES;
        button118.hidden = YES;
        button119.hidden = YES;
        button120.hidden = YES;
        button121.hidden = YES;
        button122.hidden = YES;
        button123.hidden = YES;
        button124.hidden = YES;
        button125.hidden = YES;
        button126.hidden = YES;
        button127.hidden = YES;
        button128.hidden = YES;
        button129.hidden = YES;
    } else {

        // hide Eastern Conference teams
        button100.hidden = YES;
        button101.hidden = YES;
        button102.hidden = YES;
        button103.hidden = YES;
        button104.hidden = YES;
        button105.hidden = YES;
        button106.hidden = YES;
        button107.hidden = YES;
        button108.hidden = YES;
        button109.hidden = YES;
        button110.hidden = YES;
        button111.hidden = YES;
        button112.hidden = YES;
        button113.hidden = YES;
        button114.hidden = YES;
               // show Western Conference teams
        button115.hidden = NO;
        button116.hidden = NO;
        button117.hidden = NO;
        button118.hidden = NO;
        button119.hidden = NO;
        button120.hidden = NO;
        button121.hidden = NO;
        button122.hidden = NO;
        button123.hidden = NO;
        button124.hidden = NO;
        button125.hidden = NO;
        button126.hidden = NO;
        button127.hidden = NO;
        button128.hidden = NO;
        button129.hidden = NO;
    }
}

/**
 *
 * Change this string to fit the query?
 */
- (IBAction)buttonPressed:(id)sender {
    
    switch ([sender tag]) {
        case 100: teamName = @"Boston Bruins"; break;
        case 101: teamName = @"Buffalo Sabres"; break;
        case 102: teamName = @"Carolina Hurricanes"; break;
        case 103: teamName = @"Florida Panthers"; break;
        case 104: teamName = @"Montreal Canadiens"; break;
        case 105: teamName = @"New Jersey Devils"; break;
        case 106: teamName = @"New York Islanders"; break;
        case 107: teamName = @"New York Rangers"; break;
        case 108: teamName = @"Ottawa Senators"; break;
        case 109: teamName = @"Philadelphia Flyers"; break;;
        case 110: teamName = @"Pittsburgh Penguins"; break;
        case 111: teamName = @"Tampa Bay Lightning"; break;
        case 112: teamName = @"Toronto Maple Leafs"; break;
        case 113: teamName = @"Washington Capitals"; break;
        case 114: teamName = @"Winnipeg Jets"; break;
        case 115: teamName = @"Anaheim Ducks"; break;
        case 116: teamName = @"Calgary Flames"; break;
        case 117: teamName = @"Chicago Blackhawks"; break;
        case 118: teamName = @"Colorado Avalanche"; break;
        case 119: teamName = @"Columbus Blue Jackets"; break;
        case 120: teamName = @"Dallas Stars"; break;
        case 121: teamName = @"Detroit Red Wings"; break;
        case 122: teamName = @"Edmonton Oilers"; break;
        case 123: teamName = @"Los Angeles Kings"; break;
        case 124: teamName = @"Minnesota Wild"; break;
        case 125: teamName = @"Nashville Predators"; break;
        case 126: teamName = @"Phoenix Coyotes"; break;
        case 127: teamName = @"San Jose Sharks"; break;
        case 128: teamName = @"St Louis Blues"; break;
        case 129: teamName = @"Vancouver Canucks"; break;
        default:  teamName = @"Invalid Team."; break;
    }
    
//    printf("You chose the %s\n", [teamName UTF8String]);
    
    // open team info page here. pass teamName to view.
    // not working right now.
    
    [self performSegueWithIdentifier:@"ToTeamInfoPage" sender:self];
}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"ToTeamInfoPage"]) {
        TeamInfoViewController *destViewController = segue.destinationViewController;
        destViewController.fullName = teamName;
    }
}

@end
